#ifndef WINAMPIN_H
#define WINAMPIN_H

//Include Files
#include <windows.h>
#include "SDKInc\\in2.h"
#include "SDKInc\\wa_ipc.h"
#include <dshow.h>
#include "resource.h"
#include <stdio.h>
#include <shellapi.h>
#include <atlbase.h>
#include <algorithm>
#include <Vector>
#include <map>
#include <list>

using namespace std;

//Pre defined messages and IDs
#define WM_MOUSEWHEEL 0x020A
#define WM_UNKNOWN_MSG 0x00AE
#define WM_PRIV_NOTIFY (WM_APP + 1)

#define ID_PLUGIN (WM_APP + 2)
#define ID_EXTEFF (WM_APP + 200)
#define ID_EFFECT (WM_APP + 500)


#define WM_GRAPHNOTIFY (WM_USER + 15)
#define ID_TIME (WM_USER + 16)

//Define Strings
#define CLASSNAME "MainMovieWindow"
#define FULLCLASSNAME "FullscreenMovieWindow"
#define TEST MessageBox(0,"Test","TestWindow",0)

//Skin Define Numbers.
#define NO_OF_SKINMENU 150
#define NO_SKIN_BITMAP 8

//String Buffer Sizes used in Skin
#define SMALL_BUF_SIZE 50
#define EXT_BUF_SIZE 4
//Default String Buffer size
#define STR_BUF 50

//Minimum Window sizes
#define MIN_WINDOW_SIZEX 77
#define MIN_WINDOW_SIZEY 77

//Effect Menu Defines
#define NO_OF_EXTEFF 150
#define MAX_SUB_EFF_MENU 12
#define INDEX_OF_EXEFF 0
#define MENU_MAX_COUNT 15
#define IDS_START 1
#define IDS_END 176

//Render
#define TOT_NO_OF_RENDER_TYPES 4
#define RENDER_DEFAULT 0
#define RENDER_VMR 1
#define RENDER_VMRMIXING 2
#define RENDER_ADVRENDER 3
//Decode
#define TOT_NO_OF_DECODE_TYPES 7
#define ADDON_FFDSHOW 1
#define ADDON_GPLMPEG 2
#define ADDON_LIGOS 3
#define ADDON_NERO 4
#define ADDON_FRAUNHOFER 5
#define ADDON_INTER 6
//Audio Effect
#define TOT_NO_OF_AUDIOEFFECT_TYPES 5
#define AUDIOEFFECT_FFDSHOW 1
#define AUDIOEFFECT_MATRIXMIXER 2
#define AUDIOEFFECT_INTER 3
#define AUDIOEFFECT_DCDSP 4

//Video Effect
#define TOT_NO_OF_VIDEOEFFECT_TYPES 2
#define VIDEOEFFECT_FFDSHOW 1
#define VIDEOEFFECT_INTERWINDVD 2

//Filter File Names
#define KANNANS_EFFECTFILTER_FILENAME "Filter.dll"
#define KANNANS_RENDERFILTER_FILENAME "AdvVideoRender.ax"

class AuSample{
public:
	virtual int open(int,int,int)=0;
	virtual int write(BYTE*,int,int,int,int)=0;
	virtual void close()=0;
	virtual void flush()=0;

};

class Audio:public AuSample{
public:
	int Enable;
public:
	Audio();
	int open(int,int,int);
	int write(BYTE*,int,int,int,int);
	void close();
	void flush();
};

/*typedef struct
{
	
	// dsp plug-in processing:
	// (filled in by winamp, called by input plug)

	int (*dsp_dosamples)();
	int (*dsp_isactive)();
	// eq stuff
	AuSample* (*GetData)(); // 0-64 each, 31 is +0, 0 is +12, 63 is -12. Do nothing to ignore.


} DspMod;
*/
DECLARE_INTERFACE_(IAdvVideoRenderer,IUnknown)
{

	STDMETHOD (SetRenderMethod)(THIS_ int iMethod,int iResizeMethod)PURE;
	
};
DECLARE_INTERFACE_(IFilterInterface,IUnknown)
{

	STDMETHOD (SetOptions)(THIS_ int topt)PURE;
	STDMETHOD (SelectConfigure)(THIS_)PURE;
	STDMETHOD (SetSmooth)(THIS_ int topts)PURE;
	STDMETHOD (SetExtEff)(THIS_ int teopt)PURE;
	STDMETHOD (SetExtEff)(THIS_ char*fname)PURE;
	STDMETHOD (SetConfigure)(THIS_ HWND hwnd)PURE;
	STDMETHOD (SetStop)(THIS_)PURE;

};

DECLARE_INTERFACE_(IAuFilter,IUnknown)
{
	STDMETHOD(SetDspfunction)(THIS_ AuSample*)PURE;
	STDMETHOD(SetStop)(THIS_)PURE;
};


typedef struct tagInfo
{
	HWND        hwnd;
	HWND		hwndfull;
	char        PlayingFileName[MAX_PATH];
	OAHWND      hwnddrain;
	POINT       CurPos;
	BOOL        WindowMovementflag;
	int         CapHeight;
	int         Xborder,Yborder;
	HMENU       hmenumain;
	HMENU		hMenuSkin;
	HMENU		hMenuMainEffect;
	HMENU		hMenuEffect[MAX_SUB_EFF_MENU];
	int         iSkinCount;
	char        Path[MAX_PATH];

	BOOL        EnableEffect;
	BOOL        EnableDSPEffect;
	BOOL        EnableAspectRatio;
	BOOL        EnableExtEff;
	BOOL		EnableSmooth;
	BOOL		EnableAutoSkin;

	int			iExternalEffectCount;
	BOOL        FullScreenFlag;

	HWND        hWndAbout;
	int         AboutprocTimerCount;
	int			iTimerIncrement;
	HCURSOR     hCursor;
	UINT        AboutID;

	int			iSetRenderMethod;
	int			iDecodeMethod;
	int			iVideoEffectMethod;
	int			iAudioEffectMethod;

	BOOL		ShowFilterProperty;

}Info;

typedef struct tagSkinMenu
{
	char Path[MAX_PATH];
	DWORD Menuid;
}SkinMenu;

typedef struct tagGraph
{
	IGraphBuilder *pGraphFilter;
	IMediaControl *pIMediaControl;
	IMediaPosition *pIMediaPosition;
	IVideoWindow *pIVideoWindow;
	IMediaEventEx *pIEvent;

	IBasicAudio *pIBasicAudio;
	IBasicVideo *pIBasicVideo;
	

	IFilterInterface *pIVideoEffect;
	IAuFilter *pIAudioEffect;

	IBaseFilter *pVideoEffectFilter;
	IBaseFilter *pAudioEffectFilter;
	IBaseFilter *pColorSpaceFilter;
	IBaseFilter *pVideoRenderFilter;
	//Addon Pack;
	IBaseFilter *pVideoDecoderFilter;
	IBaseFilter *pAudioDecoderFilter;

}Graph;


typedef struct tagSkin
{
	HBITMAP hbit;
	BITMAP bmp;
	HDC mhdc;
}Skin;

//Vector typedefs........

typedef vector<SkinMenu> tagvecSkinMenu;

void About(HWND);
void Init(void);
void Quit(void);
int  IsOurFile(char *);
int  Play(char*);
void Pause(void);
void UnPause(void);
int  IsPaused(void);
void Stop(void);
int  GetLength(void);
int  GetOutputTime(void);
void SetOutputTime(int);
void SetVolume(int);
void SetPan(int);
void GetFileInfo(char *, char *, int *);
int  infoDlg(char *, HWND);
void SetFileName(char*);
//AuFilter
int  dsp_dosamples(void);
int  dsp_isactive(void);

LRESULT CALLBACK CustomFullScreenWndproc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
LRESULT CALLBACK MainWindowproc(HWND,UINT,WPARAM,LPARAM);
BOOL    CALLBACK Aboutproc(HWND,UINT,WPARAM,LPARAM);
BOOL    CALLBACK Configproc(HWND,UINT,WPARAM,LPARAM);
BOOL    CALLBACK Helpproc(HWND,UINT,WPARAM,LPARAM);
BOOL    CALLBACK Historyproc(HWND,UINT,WPARAM,LPARAM);
BOOL    CALLBACK ConfigMainproc(HWND,UINT,WPARAM,LPARAM);
BOOL    CALLBACK Propertiesproc(HWND,UINT,WPARAM,LPARAM);


HRESULT RegisterDll(LPSTR szDll, BOOL bRegister);
HRESULT EnumFilters (IGraphBuilder *pGraph, HWND hList);
HRESULT ShowFilterPropertyPage(IBaseFilter *pFilter , HWND hwnd);
HRESULT ShowFilterPropertyPageByName(IGraphBuilder *pGraph ,const char *ptName , HWND hwnd);

void Release(void);
void InitPlay(void);
void ToggleFullScreen(void);
void InitSkinDir(void);
int  ProcessSkinMenu(DWORD opt);
void InitFilterMenu(void);
int  Paint(HWND);
int  Registermainclass(void);
void ProcessCommand(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
void DisplayInfo(char * pstrBuf,char * pstrTitle);
void ProcessKeyDown(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);

void LoadSkin(void);
void UnloadSkin(void);
void InitSkin(void);
void SelectDecodeFilter(void);
void SelectAudioEffectFilter(void);
void SelectVideoEffectFilter(void);
void SelectRenderFilter(void);
void InstallFilter(void);
void ShowAddOnAudio(void);
void ShowAddOnVideo(void);
void ShowAddOnAudioEffect(void);
void ShowAddOnVideoEffect(void);
void ShowRender(void);
void InitThirdFilter(BOOL bFlag);
#endif

